package com.belizer.demo.list;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Demo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        ArrayList<String> stringList= new ArrayList<>(Arrays.asList("1", "2", "3", "4", "3"));

        Iterator<String> stringIterator = stringList.iterator();
        while (stringIterator.hasNext()){
            String str = stringIterator.next();

            if(!list.contains(str)){
                list.add(str);
            }else {
                stringIterator.remove();
            }
        }

        System.out.println(stringList);
    }
}
